<?php

function prepare_package($encoding, $path)
{
	logging\info("---- 开始打包 %s ----", $encoding);
	$target_path = join_paths("dist", $encoding);
	cpdir($path, $target_path);

	// ipdata
	$src = join_paths("dzfile/ipdata", $encoding, "tinyipdata.dat");
	$target = join_paths($target_path, "upload/data/ipdata/tinyipdata.dat");
	logging\info("复制ipdata文件 %s -> %s", $src, $target);
	copy($src, $target);

	if (starts_with($encoding, "TC_")) {
		// 繁体图片
		$src = "dzfile/image_big5";
		$target = join_paths($target_path, "upload/static/image");
		logging\info("复制繁体图片文件", $src, $target);
		copy_all_files($src, $target);

		convert_to_zh_hant($target_path);
		css_replace_simsun_with_mingliu($target_path);
	}
	
	// 转换编码
	if (ends_with($encoding, "_GBK")) {
		convert_encoding_in($target_path, 'gbk');
	}
	if (ends_with($encoding, "_BIG5")) {
		convert_encoding_in($target_path, 'big5');
	}


}

?>